package fr.mbds.first.wallet.Activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import fr.mbds.first.wallet.R;

public class ValidateOperationActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_validate_operation);
		
		final EditText codePINEditText = (EditText) findViewById(R.id.EditText_ValidateOperation_CodePIN);
		
		TextView detailsTextView = (TextView) findViewById(R.id.TextView_ValidateOperation_OperationDetailsLabel);
		TextView valueTextView = (TextView) findViewById(R.id.TextView_ValidateOperation_OperationValueLabel);
		
		Bundle extras = getIntent().getExtras();
		String details = extras.getString("details");
		String value = extras.getString("value");
		
		detailsTextView.setText(details);
		valueTextView.setText(value);
		
		Button okButton = (Button) findViewById(R.id.Button_ValidateOperation_Ok);
		Button cancelButton = (Button) findViewById(R.id.Button_ValidateOperation_Cancel);
					
		okButton.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				String mdp = codePINEditText.getText().toString();
				if(mdp.equals("")){
					String errorMessage = getResources().getString(R.string.error_nopincode);
					Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_LONG).show();
				}else{
					if(isPinValid(mdp)){

					}else{
						String errorMessage = getResources().getString(R.string.error_unvalidpincode);
						Toast.makeText(getApplicationContext(), errorMessage, Toast.LENGTH_LONG).show();
					}
				}

			}
        	
        });
		
		cancelButton.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View v) {
				finish();
			}
        	
        });
	}
	
	private boolean isPinValid(String mdp){
		return true;
	}
	
}
